const EventEmitter = require('events');

class MyStream extends EventEmitter {
    write(data) {
        this.emit('data', data);
    }
}

const stream = new MyStream();

stream.on('data', (data) => {
    console.log(`Received data: "${data}"`);
});
stream.write('With ES6');
